<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="common/include :: header('客户列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="post-form">
                <div class="select-list">
                    <ul>
                        <li>
                            客户名称：<input type="text" name="name"/>
                        </li>


                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:customer:add">
                <i class="fa fa-plus"></i> 新增
            </a>
            <a class="btn btn-primary single disabled" onclick="$.operate.edit()"
               shiro:hasPermission="system:customer:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()"
               shiro:hasPermission="system:customer:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:customer:export">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>

        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="common/include :: footer"/>
<script th:inline="javascript">

    var prefix = ctx + "/system/customer";
    $(function () {
        // options 定义分页 新增url，删除url，属性
        // options 简单的理解就是我们界面中可能要用到的一些属性
        var options = {
            url: prefix + "/query",						// 查询url
            createUrl: prefix + "/addPage",				// 跳转到新增界面url
            updateUrl: prefix + "/editPage?id={id}",	// 跳转到编辑界面url
            removeUrl: prefix + "/remove",				// 删除url
            exportUrl: prefix + "/export",				// 导出url
            sortName: "seq",							// 根据这个字段进行排序
            modalName: "客户",							// 模态框名称
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',							// 字段名字
                    title: '客户id',						// 标题头名字
                    visible: false							// 是否隐藏 设置成false隐藏窗台
                },
                {
                    field: 'name',
                    title: '客户名称',
                    sortable: true
                },

                {
                    field: 'phone',
                    title: '客户手机',
                    sortable: true
                },
                {
                    field: 'age',
                    title: '客户年龄',
                    sortable: true
                },


                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" ' +
                            'onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');

                        actions.push('<a class="btn btn-danger btn-xs " href="javascript:void(0)"' +
                            ' onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });
</script>
</body>
</html>